// 场景管理
controllers.controller('businessAccountListCtrl', ['$scope', '$http', '$rootScope', '$modal', '$window', 'BusinessAccount', 'AlertService', function ($scope, $http, $rootScope, $modal, $window, BusinessAccount, AlertService) {
    $scope.resetCurrentPageName("V币维护");
    $scope.utils = Food.utils;
    $scope.pageSize = 20;
    $scope.currentPage = 1;
    $scope.businessAccountList = BusinessAccount.businessAccountList;

    $scope.queryList = function () {
        BusinessAccount.queryList($scope.currentPage, $scope.pageSize, $scope.memberId, $scope.companyName, $scope.type, $scope.amount, $scope.userAdd,$scope.userEdit, function () {
            $scope.totalCount = BusinessAccount.totalCount;
        });
    };
    $scope.downItem = function (itemId) {
        Item.downItem(itemId, function () {
            $scope.totalItems = Item.totalSceneCount;
        });
    };
    $scope.initUpdateItem = function (item) {

        Item.currentItem = item;
        $window.location.href = "#item/updateItem";

    };
    $scope.queryList();

    var operateTemplate = "<button class='btn btn-primary btn-sm' ng-click='grid.appScope.initUpdateItem(row.entity)'>修改</button>" +
        "<button class='btn btn-primary btn-sm' ng-click='grid.appScope.downItem(row.entity.id)'>下架</button>";

    $scope.gridOptions = {
        data: 'businessAccountList',
        enableColumnMenus: false,
        enableColumnResizing: true,
        rowHeight: 100,
        columnDefs: [

            {
                field: 'memberId',
                displayName: '会员ID',
                cellTemplate: '<div>{{row.entity.memberId}}</div>'
            },
            {
                field: 'companyName',
                displayName: '公司名称',
                width: "10%",
                cellTemplate: '<div>{{row.entity.companyName}}</div>'
            },
            {
                field: 'type',
                displayName: '类型',
                cellTemplate: '<div>{{row.entity.type}}</div>'
            },
            {
                field: 'amount',
                displayName: '可用',
                cellTemplate: '<div>{{row.entity.amount}}</div>'
            },
            {
                field: 'userAdd',
                displayName: '用户增加',
                cellTemplate: '<div>{{row.entity.userAdd}}</div>'
            },
            {
                field: 'userEdit',
                displayName: '用户编辑',
                cellTemplate: '<div>{{row.entity.userEdit}}</div>'
            }
        ]
    };
}]);


